﻿/*
 *  Copyright 2012 Cloudbase Solutions Srl
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the Microsoft Public License (Ms-PL).  
 */

using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Web.Management.Server;
using System.Reflection;

namespace Cloudbase.Iis.HostsFileManager.Server
{
    internal static class AssemblyRef
    {
        private static string client;

        internal static string Client
        {
            get
            {
                if (client == null)
                {
                    AssemblyName assemblyName = typeof(AssemblyRef).Assembly.GetName();
                    string assemblyFullName = assemblyName.FullName;
                    client = assemblyFullName.Replace(".Server", ".Client");
                }

                return client;
            }
        }
    }

    public class HostsFileManagerModuleProvider : ModuleProvider
    {
        public override Type ServiceType
        {
            get { return typeof(HostsFileModuleService); }
        }
        public override ModuleDefinition GetModuleDefinition(IManagementContext context)
        {
            return new ModuleDefinition(Name, "Cloudbase.Iis.HostsFileManager.Client.HostsFileModule," + AssemblyRef.Client);
        }
        public override bool SupportsScope(ManagementScope scope)
        {
            return true;
            //return ManagementUnit.Context.IsLocalConnection;
        }
    }
}